package com.diligreat.util; 

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.ResourceBundle;

/**  
 * @Author Bruce 
 * @Date 2012-2-18
 * @Comments
 */
public class CodeTransUtil {
	
	private CodeTransUtil(){}//私有构造函数（不允许实例化）
	
	/** The Constant BUNDLE_NAME. */
	private static final String BUNDLE_NAME = "conf/statusCodeTrans";

	/** The RESOURC e_ bundle. */
	private static ResourceBundle RESOURCE_BUNDLE = null;
	
	/** 语言分类的文字抓换 */
	public static Map<String,String> langInfo = new HashMap<String, String>();
	
	static{
		init();
	}

	private static void init(){
		RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME, Locale.CHINA);
	}
	/**
	 * Gets the string.
	 * @param key the key
	 * @param locale the locale
	 * @return the string
	 */
	public static String getText(String key) {
//		if(key.startsWith("lang.")){
//			return getLangName(key.replace("lang.", ""));
//		}else{
			if(RESOURCE_BUNDLE == null){
				init();
			}
			if(RESOURCE_BUNDLE.containsKey(key)){
				return RESOURCE_BUNDLE.getString(key);
			}else{
				return "";
			}
//		}
	}
	
	/**
	 * 
	 * @param langId
	 * @return
	 */
	public static String getLangName(String langId){
		return langInfo.get(langId);
	}
}
 